﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SGGWElevator
{
    /// <summary>
    /// Interaction logic for ElevatorDoorPanel.xaml
    /// Author: Adrian Surowik
    /// </summary>
    public partial class ElevatorDoorPanel : UserControl
    {
        public ElevatorDoorPanel()
        {
            InitializeComponent();
        }


        /// <summary>
        /// Handles OpenButton click event.
        /// </summary>
        private void OnOpenButtonClick(object sender, RoutedEventArgs e)
        {
            HighlightButtonLabel(sender as Button);
        }


        /// <summary>
        /// Handles CloseButton click event.
        /// </summary>
        private void OnCloseButtonClick(object sender, RoutedEventArgs e)
        {
            HighlightButtonLabel(sender as Button);
        }
        

        /// <summary>
        /// Highlights given buttons label.
        /// </summary>
        void HighlightButtonLabel(Button button)
        {
            if (object.ReferenceEquals(button, OpenButton))
            {
                // Highlight OpenButtons label

                OpenButton.Dispatcher.Invoke(new Action(delegate()
                {
                    LeftOpenButtonArrow.Source = new BitmapImage(new Uri(ImagePaths.ArrowLeftOn, UriKind.Relative));
                    RightOpenButtonArrow.Source = new BitmapImage(new Uri(ImagePaths.ArrowRightOn, UriKind.Relative));
                }));
            }
            else if (object.ReferenceEquals(button, CloseButton))
            {
                // Highlight CloseButtons label

                CloseButton.Dispatcher.Invoke(new Action(delegate()
                {
                    LeftCloseButtonArrow.Source = new BitmapImage(new Uri(ImagePaths.ArrowRightOn, UriKind.Relative));
                    RightCloseButtonArrow.Source = new BitmapImage(new Uri(ImagePaths.ArrowLeftOn, UriKind.Relative));
                }));
            }
        }

        /// <summary>
        /// Paths to images.
        /// </summary>
        class ImagePaths
        {
            public static readonly string ArrowLeftOn = @"/Images/ElevatorDoorPanel/arrowLeftOn.png";
            public static readonly string ArrowLeftOff = @"/Images/ElevatorDoorPanel/arrowLeftOff.png";
            public static readonly string ArrowRightOn = @"/Images/ElevatorDoorPanel/arrowRightOn.png";
            public static readonly string ArrowRightOff = @"/Images/ElevatorDoorPanel/arrowRightOff.png";
        }
    }
}
